package com.examples.calendar;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class CalendarView {
	
	public static void main(String[] args) {
		
		final Display display = Display.getDefault();
		final Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());

		Canvas canvas = new Canvas(shell, SWT.NONE);
		
		CustomPaintListener paintListener = new CustomPaintListener(display);
		canvas.addPaintListener(paintListener);
		
		MouseClickListener mouseClickListener = new MouseClickListener(canvas);
		KeyListener keyListener = new KeyboardListener(display, paintListener.getRectangle());
		
		canvas.addMouseListener(mouseClickListener);
		canvas.addKeyListener(keyListener);
		
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		//display.dispose(); //Commented only for SWTShowcase application.
	}
}
